import request from '@/utils/request'

// 查询商品分类列表
export function listCategory(query) {
  return request({
    url: '/store/category/list',
    method: 'get',
    params: query
  })
}

// 查询商品分类详细
export function getCategory(id) {
  return request({
    url: '/store/category/' + id,
    method: 'get'
  })
}

// 新增商品分类
export function addCategory(pram) {
  const data = {
    extra: pram.extra,
    name: pram.name,
    pid: pram.pid,
    sort: pram.sort,
    status: pram.status,
    type: pram.type,
    url: pram.url
  }
  return request({
    url: '/store/category',
    method: 'post',
    data: data
  })
}

// 修改商品分类
export function updateCategory(data) {
  return request({
    url: '/store/category',
    method: 'put',
    data: data
  })
}

// 删除商品分类
export function delCategory(id) {
  return request({
    url: '/store/category/' + id,
    method: 'delete'
  })
}

// 导出商品分类
export function exportCategory(query) {
  return request({
    url: '/store/category/export',
    method: 'get',
    params: query
  })
}

/**
 * 分类数据tree数据
 * @param pram
 */
 export function treeCategory(pram) {
  const data = {
    type: pram.type,
    status: pram.status,
    name: pram.name
  }
  return request({
    url: '/store/category/list/tree',
    method: 'GET',
    params: data
  })
}
